<!DOCTYPE html>
<html>
<#include "/views/ftl/base/manager_include.ftl">
<script type="text/javascript" src="${basePath}js/My97DatePicker/WdatePicker.js"></script>
<base href="${basePath}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户列表</title> 
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script> 
<script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script> 
</head>
<body style="background:#eef3f7;">
<#include "/views/ftl/base/head.ftl"> 
<div class="Main">
  <div class="dw">
<#include "/views/ftl/base/menu.ftl">
<#function a><#return "新闻列表_List"></#function> 

 <!--右边内容-->
      <div class="Rightbox fl">
        <!--面包屑-->
        <div class="Bread_crbs clear">
          <div class="Bread_crbs_img fl"></div>
          <div class="Bread_crbs_text fl"><a href="javascript:;"><span>内容管理</span></a><span class="fnt_famy">></span><a href="javascript:;"><span>编辑内容页面</span></a></div>
        </div>  
        <!--各种表单设置-->
        <div class="bd_box">
         <input type="hidden" name="newsId" value='${(news.id)?c}'>
          <div class="input_name">
            <span>内容标题:&nbsp; </span><input type="text" name="newsTitle" placeholder="请输入标题" value='${(news.newsTitle)!''}' /> 
          </div><br/>
          <div class="input_name"  style="display:none;">
            <span>自定义URI:</span><input type="text" name="customId" placeholder="使用字母,数字,下划线" value='${(news.customId)!''}' /><span>使用此URI访问.不填,使用默认id(最好不要用纯数字)</span>
          </div><br/>
           <div class="input_name"  style="display:none;">
            <span>浏览量:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" name="pageViews" placeholder="浏览量" value='${(news.pageViews)?c}' /><span>浏览量可修改</span>
          </div><br/> 
			<div class="input_name"><span>内容模块:</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
				<select name="newsModulesId" class="St" style="width:80px" >
					<option value="0">------------</option>
				</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</div> 
    		  	
    		<div class="input_name"><span>内容所属:</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
				<select name="isOutNews" class="St">
					<option value="0" <#if  news.isOutNews == 0 >selected='true'</#if> >站内内容</option>
					<option value="1" <#if  news.isOutNews == 1 >selected='true'</#if> >站外链接</option>
				</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
    	
    	<div class="input_name outLinkDiv"  <#if  news.isOutNews == 0 >style="display:none;"</#if>>
            <span>外部链接:</span><input type="text" name="outLink" placeholder="外部链接" value='${(news.outLink)!''}' /><span></span>
          </div><br/>
         <div  class="explain"  <#if  news.isOutNews == 1 >style="display:none;"</#if>> 
    		<script id="editor" type="text/plain" style="width:1024px;height:500px;">${(news.newsContent)!''}</script>
		</div>
        <div class="button">
           <a id='submit_form' href="javascript:void(0);"><input  type="button" name="button" value="保存" /></a>
        </div>
        
         
   </div></div>  
</div></div> 
<script type="text/javascript">  
$(function(){
	
	var ue = UE.getEditor('editor'); 
	loadallNewsModules();
	function loadallNewsModules(){
		$.ajax({
				url : 'manager/NewsModules_allNewsModules', 
				data : {
					 
				},
				dataType : "JSON",
				async : true,
				cache : false,  
				type  : "POST",
				success : function(data) {
					if(1==data.code){ 
						 var html ='<option value="0">------------</option>';
						 $(data.data).each(function(index,bean){
							 var x=bean.id;var optionValue='${(news.newsModulesId)?c}';     
							html+='<option value='+x+' '+(optionValue==x?"selected":"")+' >'+bean.modulesName+'</option>'; 
						 });
						 $('select[name=newsModulesId]').html(html);
					
					}
				}
		});
	}
	
	$('select[name=isOutNews]').change(function(){
		var isOutNews=  $('select[name=isOutNews]').val();
		if(isOutNews==1){
			$('.explain').hide();
			$('.outLinkDiv').show();
		}else{
			$('.explain').show();
			$('.outLinkDiv').hide();
		}
	});
	
	
	
	$('#submit_form').click(function(){
		var newsId=$('input[name=newsId]').val();//id 
    	var newsModulesId=$('select[name=newsModulesId]').val();//父Id
    	var newsTitle  = $('input[name=newsTitle]').val();
    	var customId = $('input[name=customId]').val();
    	var pageViews = $('input[name=pageViews]').val();
    	var outLink =$('input[name=outLink]').val();
    	var isOutNews = $('select[name=isOutNews]').val();
    	
    	var newsContent=ue.getContent();//分类简介
		 
		 $.ajax({
				url : 'manager/News_modifyNews', 
				data : {
						 customId:customId,
						 newsModulesId:newsModulesId,
						 newsTitle:newsTitle,
						 pageViews:pageViews,
						 newsContent:newsContent, 
						 newsId:newsId,
						 outLink : outLink,
						 isOutNews : isOutNews
				},
				dataType : "JSON",
				async : true,
				cache : false,  
				type  : "POST",
				success : function(data) { 
					if(1==data.code){
						alert(data.msg);
						window.location.href="${basePath}manager/News_newsList"; 
					}else{
						alert(data.msg);
					}
				}
		}); 
	});
	
}); 
</script>
</body>
</html>